package com.yincb;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Transactional(rollbackFor = Exception.class)
@Component
public class EmpDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void updateByAnnotation(Emp emp){
        try {
            String sql = "UPDATE emp SET ename = ? WHERE empno = ?";
            int update = jdbcTemplate.update(sql, emp.getEname(), emp.getEmpno());
            System.out.println(update);
//            int a = 1/0;
        } catch (Exception throwables) {
            throw new RuntimeException("0001");
        }
    }

}
